package com.ycomputer.dialogactivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class BaseDialogActivity extends Activity {

	protected Bundle bundle;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		bundle = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
		if (bundle == null) {
			bundle = new Bundle();
		}
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		if (bundle != null) {
			outState.putAll(bundle);
		}
		super.onSaveInstanceState(outState);
	}

	public void eStartActivity(Class<? extends Activity> cls) {
		eStartActivity(cls, null);
	}

	public void eStartActivity(Class<? extends Activity> cls, Bundle bundle) {
		Intent intent = new Intent();
		if (bundle != null) {
			intent.putExtras(bundle);
		}
		intent.setClass(this, cls);
		startActivity(intent);
	}

	public void eStartActivityForResult(Class<? extends Activity> cls, int requestCode) {
		eStartActivityForResult(cls, null, requestCode);
	}

	public void eStartActivityForResult(Class<? extends Activity> cls, Bundle bundle, int requestCode) {
		Intent intent = new Intent();
		if (bundle != null) {
			intent.putExtras(bundle);
		}
		intent.setClass(this, cls);
		startActivityForResult(intent, requestCode);
	}
}
